package com.abel.bigwater.dataserver.model.qdies

import com.abel.bigwater.dataserver.model.PacketDataLenException
import io.netty.buffer.ByteBuf

class DtenClearWarnData : D10BaseData(1) {
    override var type = FuncType.ClearWarn

    var clearOkay = true

    override fun fill(buf: ByteBuf) {
        buf.writeByte(if (clearOkay) 0xAA else 0xCC)
    }

    override fun parse(buf: ByteBuf): Boolean {
        if (buf.readableBytes() < count()) throw PacketDataLenException("invalid len")
        val b1 = buf.readByte()
        clearOkay = 0xFF.and(b1.toInt()) == 0xAA

        return true
    }

    override fun count(): Int = 1
}